from flask import Flask, jsonify, request
from random import choice
from mock_test_api.testcase import AnalyzeDataUtil


app = Flask(__name__)
generated_data = AnalyzeDataUtil([])


@app.route('/supply/product/detail', methods=['get'])
# 供端获取商品详情
def supply_product_detail():
    generated_data.datas = []
    data1 = generated_data.get_json_data("Supply_Product_detail")
    key_list1 = generated_data.analyze_data(data1, result="")
    random_key = choice(key_list1)
    random_function = generated_data.random_function()
    return random_function(data1, random_key)

# 未开发
# @app.route('/supply/product/category', methods=['get'])
# # 获取商品分类
# def product_category():
#     generated_data.datas = []
#     data = generated_data.get_json_data("")
#     key_list = generated_data.analyze_data(data, result="")
#     random_key = choice(key_list)
#     random_function = generated_data.random_function()
#     return random_function(data, random_key)


@app.route('/supply/product/logistics', methods=['get'])
# 获取供端商品物流信息
def supply_product_logistics():
    generated_data.datas = []
    data2 = generated_data.get_json_data("Supply_Product_logistics")
    key_list2 = generated_data.analyze_data(data2, result="")
    random_key = choice(key_list2)
    random_function = generated_data.random_function()
    return random_function(data2, random_key)


@app.route('/supply/order/list', methods=['get'])
# 获取供端订单列表
def supply_order_list():
    generated_data.datas = []
    data = generated_data.get_json_data("Supply_Order_list")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/supply/create/order', methods=['post'])
# 供端创建订单
def supply_create_order():
    generated_data.datas = []
    data = generated_data.get_json_data("Supply_Order_create")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/supply/render/order', methods=['post'])
# 供端渲染订单
def supply_render_order():
    generated_data.datas = []
    data = generated_data.get_json_data("Supply_Render_order")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/product/list', methods=['get'])
# 销端商品列表
def seller_product_list():
    generated_data.datas = []
    data = generated_data.get_json_data("Seller_Product_list")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/product/create', methods=['post'])
# 推送商品到销端
def seller_product_create():
    generated_data.datas = []
    data = generated_data.get_json_data("Seller_Product_create")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/product/replace', methods=['post'])
# 替换销端商品信息
def seller_product_replace():
    generated_data.datas = []
    data = generated_data.get_json_data("Seller_Product_replace")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/product/price', methods=['post'])
# 同步销端商品价格
def seller_product_price():
    generated_data.datas = []
    data = generated_data.get_json_data("")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/product/stock', methods=['post'])
# 同步销端商品库存 
def seller_product_stock():
    generated_data.datas = []
    data = generated_data.get_json_data("")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)

# 统一使用一个接口
# @app.route('/seller/product/stock-delete-variants', methods=['post'])
# # 同步库存删除variants到销售商
# def seller_product_stock_delete_variants():
#     generated_data.datas = []
#     data = generated_data.get_json_data("")
#     key_list = generated_data.analyze_data(data, result="")
#     random_key = choice(key_list)
#     random_function = generated_data.random_function()
#     return random_function(data, random_key)
#
#
# @app.route('/seller/product/stock-draft', methods=['post'])
# # 同步库存下架商品到销售商
# def seller_product_stock_draft():
#     generated_data.datas = []
#     data = generated_data.get_json_data("")
#     key_list = generated_data.analyze_data(data, result="")
#     random_key = choice(key_list)
#     random_function = generated_data.random_function()
#     return random_function(data, random_key)


@app.route('/seller/product/detail', methods=['get'])
# 销端商品信息
def seller_product_detail():
    generated_data.datas = []
    data = generated_data.get_json_data("Seller_Product_detail")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/store/location', methods=['get'])
# 获取销端店铺location配置
def seller_store_location():
    generated_data.datas = []
    data = generated_data.get_json_data("")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/order/create-fulfill', methods=['post'])
# 给销端创建fulfill 任务
def seller_create_fulfill():
    generated_data.datas = []
    data = generated_data.get_json_data("")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


@app.route('/seller/order/cancel-fulfill', methods=['post'])
# 给销端取消fulfill 任务
def seller_cancel_fulfill():
    generated_data.datas = []
    data = generated_data.get_json_data("")
    key_list = generated_data.analyze_data(data, result="")
    random_key = choice(key_list)
    random_function = generated_data.random_function()
    return random_function(data, random_key)


if __name__ == '__main__':
    app.run()

